#include<cstdio>
#include<cstring>
const int maxn=100010;
double dp[maxn];
int to[maxn];
int main()
{
	int n,m;
	while(scanf("%d%d",&n,&m)&&(n+m)!=0)
	{
		memset(dp,0,sizeof(dp));
		memset(to,0,sizeof(to));
		for(int i=1;i<=m;i++)
		{
			int x,y;
			scanf("%d%d",&x,&y);
			to[x]=y;
		}
		for(int i=n-1;i>=0;i--)
		{
			double a=0;
			for(int k=1;k<=6;k++)
				a+=dp[i+k];
			a=a/6.0+1;
			//if(to[i]>0)dp[i]=0.5*a+0.5*dp[to[i]];
			if(to[i]>0)dp[i]=dp[to[i]];
			else dp[i]=a;
		}
		printf("%.4lf\n",dp[0]);
	}
	return 0;
}

